package com.Jano.dao.Impl;

import com.Jano.dao.QuestionDao;
import com.Jano.entity.Question;
import org.junit.Test;

import java.util.List;

/**
 * description: QuestionDaoImpl <br>
 * date: 2022/6/6 4:31 PM <br>
 * author: zoumaoji <br>
 * version: 1.0 <br>
 */
public class QuestionDaoImpl extends AbstractDaoImpl implements QuestionDao {
    @Override
    public void createQuestion(int questionnaireId, String content) {
        update("insert into t_question (questionnaire_id,content) values(?,?)",new Object[]{questionnaireId,content});
    }

    @Override
    public List<Question> selectQuestionsByQuestionnaireId(int questionnaireId) {
        return queryForList("select id questionId,content,questionnaire_id questionnaireId from t_question where  questionnaire_id=? ",Question.class,new Object[]{questionnaireId});
    }

    @Override
    public Question selectQuestionByQuestionnaireIdAndContent(int questionnaireId, String content) {
        return queryForObject("select id questionId,content,questionnaire_id questionnaireId from t_question where  questionnaire_id=? and content=? ",Question.class,new Object[]{questionnaireId,content});
    }
}
